// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.android.apps.moderator;

import android.app.Activity;
import android.view.ContextMenu;
import android.view.View;

/**
 * Defines the appearance of a list entry to appear in synchronized ListViews.
 */
public interface ListEntry {

  /**
   * Gives the list entry an opportunity to add context menu items relating to
   * itself.
   * @param menu The context menu to add the menu items to.
   * @param activity The parent activity, can be used as a context.
   */
  public void addContextItems(ContextMenu menu, Activity activity);

  /**
   * Handle a click event on the entry.
   *
   * @param activity The parent activity, can be used as a context.
   * @return 'false' if the event can not be handled, in which case the context
   *         menu will be launched, if it exists.
   */
  public boolean clicked(Activity activity);

  /**
   * Called list synchronizers with a view inflated of the type indicated by
   * getLayoutId(). This is not necessarily a freshly-inflated view, it may be
   * an existing list entry view that is being recycled.
   *
   * @param view A view inflated from the layout supplied by getLayoutId().
   * @param activity The parent activity, can be used as a context.
   */
  public void customizeView(View view, Activity activity);

  /**
   * This method should return the R.layout.___ ID of the layout associated
   * with this list entry. The synchronizer will use this to inflate a view of
   * this type which will be supplied back to this object as the first
   * parameter of customizeView().
   */
  public int getLayoutId();

}